package com.itheima;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.function.Consumer;
import java.util.List;


/**
 * @ProjectName: ybxy6
 * @Titile: com.itheima.ArrayListDemo
 * @Author: Chilemey
 * @Description: TODO
 */
    public class ArrayListDemo {
        public static void main(String[] args) {
            ArrayList<String> arrayList=new ArrayList<String>();
            arrayList.add("zhangsan");
            arrayList.add(0,"wangwu");
            arrayList.add("zhaoliu");
            System.out.println(arrayList.get(1));
            arrayList.remove(0);
            System.out.println(arrayList);
            arrayList.set(1,"lisi");
            System.out.println(arrayList);
            System.out.println("--------------------集合的遍历方法--------------------");
            for(int i=0;i<arrayList.size();i++){
                System.out.println(arrayList.get(i));
            }
            System.out.println("--------------------迭代器方式--------------------");
            Iterator<String> iterator=arrayList.iterator();
            while(iterator.hasNext()){
                System.out.println(iterator.next());
            }
            System.out.println("--------------------增强for--------------------");
            for (String obj : arrayList){
                System.out.println(obj);
            }
            System.out.println("--------------------匿名内部类方式--------------------");
            arrayList.forEach(System.out::println);
        }



}


